package com.myr.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author myr
 * @version 1.0
 * @date 2022/11/18 15:55
 */
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("myr")//组名
                .apiInfo(getInfo())//api信息
                .select()//选择生成那些api接口-- 根据路径选择 2.根据包名选择
                .apis(RequestHandlerSelectors.basePackage("com.myr.controller")).build();
        return docket;
    }

    private ApiInfo getInfo() {
        Contact DEFAULT_CONTACT = new Contact("马逸然", "http://www.jd.com", "2805998599@qq.com");
        ApiInfo info = new ApiInfo("用户查询", "用户查询", "2.0", "http://www.jd.com",
                DEFAULT_CONTACT, "哈哈", "http://www.jd.com", new ArrayList<VendorExtension>());
        return info;
    }
}
